package com.pashanhoo.Thread.yuanli;

/**
 * @author 胡庆安
 * @version V1.0
 * @Package com.pashanhoo.Thread.yuanli
 * @date 2020/12/21 17:40
 * @Copyright © 2010-2021 爬山虎科技（扬州）有限公司
 */
public class VoliteDemo {
    volatile static Temp temp = new Temp();
    public static void main(String[] args) {
        for (int i=1;i<=10;i++){
            Thread thread = new Thread(new voliateTask(temp));
            thread.start();
        }
        while (temp.i == 0){
            if (temp.i != 0){
                break;
            }
        }
    }
}

class voliateTask implements Runnable{
    private Temp temp;
    public voliateTask(Temp temp){
        this.temp = temp;
    }
    @Override
    public void run() {
        temp.i++;
    }
}

class Temp{
    int i = 0;
}
